package com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.dto.MaterielSupplierDeviationCountDto;
import com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.dto.MaterielSupplierDeviationItemDto;
import com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.dto.MaterielSupplierDeviationListDto;
import com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.dto.MaterielSupplierDeviationTopDto;
import com.qzsoft.zhjd.materiel.modules.materielsupplierdeviation.service.MaterielSupplierDeviationService;

/**
 * @ClassName MaterielSupplierDeviationController
 * @Description 供货商供货偏差控制器
 * @author linhuawei
 * @since 2022-04-02
 */
@RestController
@RequestMapping("/api/materielSupplierDeviation")
public class MaterielSupplierDeviationController {

    @Autowired
    private MaterielSupplierDeviationService materielSupplierDeviationService;

    /**
     * @Title count
     * @Description 获取统计信息（本期、累计对比）
     * @param params 查询条件
     * @return 统计信息
     */
    @RequiresPermissions("materiel:supplierdeviation")
    @GetMapping("/count")
    public Result<Map<String, MaterielSupplierDeviationCountDto>> count(@RequestParam Map<String, Object> params) {
        Map<String, MaterielSupplierDeviationCountDto> data = materielSupplierDeviationService.count(params);
        return ResultUtils.ok(data);
    }

    /**
     * @Title top5
     * @Description 获取偏差排行top5（本期、累计对比）
     * @param params 查询条件
     * @return 偏差排行top5
     */
    @RequiresPermissions("materiel:supplierdeviation")
    @GetMapping("/top5")
    public Result<Map<String, List<MaterielSupplierDeviationTopDto>>> top5(@RequestParam Map<String, Object> params) {
        Map<String, List<MaterielSupplierDeviationTopDto>> data = materielSupplierDeviationService.top5(params);
        return ResultUtils.ok(data);
    }

    /**
     * @Title pageForSupplier
     * @Description 按供应商分组偏差率列表
     * @param params 查询条件
     * @return 按供应商分组偏差率列表
     */
    @RequiresPermissions("materiel:supplierdeviation")
    @GetMapping("/pageForSupplier")
    public Result<IPage<MaterielSupplierDeviationListDto>> pageForSupplier(@RequestParam Map<String, Object> params) {
        IPage<MaterielSupplierDeviationListDto> data = materielSupplierDeviationService.pageForSupplier(params);
        return ResultUtils.ok(data);
    }


    /**
     * @Title pageForItem
     * @Description 按材料分组偏差率列表
     * @param params 查询条件
     * @return 按材料分组偏差率列表
     */
    @RequiresPermissions("materiel:supplierdeviation")
    @GetMapping("/pageForItem")
    public Result<IPage<MaterielSupplierDeviationItemDto>> pageForItem(@RequestParam Map<String, Object> params) {
        IPage<MaterielSupplierDeviationItemDto> data = materielSupplierDeviationService.pageForItem(params);
        return ResultUtils.ok(data);
    }
}
